package misc
{
	public class c_MATH
	{
		public function c_MATH()
		{
		}
		/** returns only the rest of a floating point number:
		 * e.g. 1.234 -> 0.234**/
		public function WholeNumberAndRest(INPUT:Number):Object
		{
			var RESULT:Object = new Object();
			var INPUT_STRING:String = INPUT.toString();
			var INPUT_ARRAY:Array = INPUT_STRING.split(".");
			RESULT["WHOLE"] = parseFloat(INPUT_ARRAY[0]);
			RESULT["REST"] = parseFloat("0."+INPUT_ARRAY[1]);
			if(isNaN(RESULT["REST"]))
			{
				RESULT["REST"] = 0;
			}
			if(isNaN(RESULT["WHOLE"]))
			{
				RESULT["WHOLE"] = 0;
			}
			return RESULT;
		}
		
		/** returns the whole number from a floating point
		 * e.g. 1.234 -> 1 **/
		public function wholeNumber(INPUT:Number):Number
		{
			var OBJECT:Object = WholeNumberAndRest(INPUT);
			
			return OBJECT["WHOLE"];
		}
		/** returns the whole number from a floating point
		 * e.g. 1.234 -> 1 **/
		public function rest(INPUT:Number):Number
		{
			var OBJECT:Object = WholeNumberAndRest(INPUT);
			
			return OBJECT["REST"];
		}
	}
}